<?php
class GBTmpFilesThread
{
	public function clean()
	{
		$dp = opendir(constant('PATH_ORDER_EDITING_DIR'));
		if(!$dp)
			throw new Exception('permission no allowed to open dir '.$dir);
		 while (($file=readdir($dp)) != false) {
		 	if(substr($file,0,1) == '.')
				continue;
			$filePath = constant('PATH_ORDER_EDITING_DIR').'/'.$file;
			if(!is_file($filePath))
				continue;
	 		$lastModify = filemtime($filePath);
	 		if($lastModify)
	 		{
	 			$expire_time = time() - $lastModify;
	 			//delete one week beform files
	 			if($expire_time > 60*60*24*7)
	 			{
	 				unlink($filePath);
	 			}
	 		}
		 }
		 closedir($dp);
	}
}
?>